export enum FapiaoListConfig {
  SELECT = 'Fapiao_SEL_L',
}

const baseUrl = '/asm/fapiao';

export const apiUrl = {
  privatePage: `${baseUrl}/privatePage`, // 私有发票
  publicPage: `${baseUrl}/publicPage`, // 公用发票
  del: `${baseUrl}/delete`, // 公用发票,
  pageDetail: '/afm/privateFile/pageDetail',
};

/**
 * 跳转页面参数转换
 * @param pathname
 * @param dataRef
 * @param index
 * @param history
 * @param pageCode
 * @param pageType
 * @param source
 */
export const handleParams = (
  pathname: string,
  dataRef: any,
  index: number,
  history: any,
  pageCode: any,
  pageType: 'DETAIL' | 'NORMAL',
  source: 'PRIVATE' | 'PUBLIC',
) => {
  if (
    !dataRef ||
    !dataRef.current ||
    !dataRef.current.content ||
    dataRef.current.content.length <= 0
  ) {
    return;
  }
  const attachmentCode: any[] = [];
  for (const item of dataRef.current?.content) {
    attachmentCode.push({
      No: item?.attachmentCode,
      type: item?.invoiceType,
    });
  }
  history.push({
    pathname,
    params: {
      keys: index,
      attachmentCode: attachmentCode,
      pageCode,
      pageType,
      source,
    },
  });
};
